ImageDivider

Dividing an image into euqal halves using OpenCV

Requirements

pip install opencv-python

Steps

  • Navigate to this folder.
  • Upload an image of your choice.
  • Tweak the code by changing the file name to your name
  • Hit run and you are done!!

Note: This code will divide the images vertically.

Demo:

Source Code: ImageDivider.py

import cv2

img = cv2.imread('imaag.jpg')
height,width,channels= img.shape

left = img[:,:width//2]
right = img[:,width//2:]

cv2.imshow('original', img)
cv2.imshow('Left Half', left)
cv2.imshow('Right half', right)

cv2.imwrite('Left.jpg', left)
cv2.imwrite('Right.jpg', right)
cv2.waitKey(0)